const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
// const manifest = require('../dll/dll.manifest.json');

module.exports = merge(common, {
  mode: 'development',
  devtool: 'cheap-module-eval-source-map',
  devServer: {
    contentBase: [path.resolve(__dirname, '../public') /* path.resolve(__dirname, '../dll') */],
    hot: true,
    port: '8000',
    // host: '0.0.0.0',
    disableHostCheck: true,
    // useLocalIp: true
  },
  output: {
    filename: '[name].js',
    chunkFilename: '[name].js',
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    // new webpack.DllReferencePlugin({
    //   manifest,
    //   context: path.resolve(__dirname, '../src'),
    // }),
  ],
  optimization: {
    splitChunks: {
      chunks: 'all',
      // 文件名连接符
      automaticNameDelimiter: '-',
      cacheGroups: {
        vendor: {
          name: 'vendor',
          chunks: 'all',
          test: /[\\/]node_modules[\\/]/,
          priority: -10,
        },
      },
    },
    runtimeChunk: 'single',
    moduleIds: 'hashed',
  },
});
